package com.lx.api;

import com.alibaba.fastjson.JSONObject;
import com.lx.api.response.ResponseEntity;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
public class BaseRestController {
    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    protected Date getCurrentDate(){
        return new Date();
    }








    @ExceptionHandler(value = Exception.class)
    public ResponseEntity genExceptionHandler(HttpServletRequest req, Exception e) throws Exception {
        logger.error(e.toString());
        ResponseEntity responseObject = new ResponseEntity();
        responseObject.setStatus(204);
        responseObject.setMessage(e.getMessage());
        logger.error("接口异常，发出的接口信息为："+responseObject.toString());
        return responseObject;
    }








}
